<template>
    <div>
        <h1 class="title">订单详情</h1>
        <div class="detail">
             <p class="num">订单编号:{{list.order_number}}</p>
            <p style="color: rgb(194, 194, 194);">{{this.date}}</p>
            <button @click="confirm(list.id)">业务员确认订单</button>
        </div>
    </div>
</template>
<script>
import api from "../../libs/js/integralAjax"
export default {
    data(){
        return{
            list:[],
            date:'',
            id:'',
            token:''
        }
    },
    created(){
        this.token = this.$store.state.options.user.token
        this.id = this.$store.state.options.user.goods_id
        this.getOrderDetail()
    },
    methods:{
        getOrderDetail:async function(){
            
            var url='/api/admin/integral/order/GetOne'
            var param={
                id:this.$route.params.id,
                token:this.token
            }
            this.$util.postRequestInterface(url, param, (res) => {
                 console.log(res.data)
                this.list = res.data
                this.date = res.data.create_time
                this.time(this.date)
            })
        
        },
        confirm:async function(id){
            var url='/api/admin/integral/order/confirmIntegralOrder'
            var param={
                id:id,
                token:this.$store.state.options.user.token
            }
            this.$util.postRequestInterface(url, param, (res) => {
                console.log(res)
                if(res.code==200){
                    alert('确认成功')
                    this.$router.push({
                        name:'SaleIntegralOrderList',
                        params:{
                            token : this.$store.state.options.user.token,
                        }
                    })
                }else{
                    alert('失败')   
                }   
            })
        },
        time(e){
            var date = new Date(e * 1000);
            var Y = date.getFullYear() + '-';
            var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
            var D = date.getDate() + ' ';
            var h = date.getHours() + ':';
            var m = date.getMinutes() + ':';
            var s = date.getSeconds();
            console.log(Y+M+D+h+m+s)
            this.date = Y+M+D+h+m+s;
        }
    }
}
</script>
<style lang="scss" scoped>
    .title{
        text-align: center;
    }
    .detail{
        width: 100rem;
        height: 22rem;
        margin: 0 auto;
        margin-top:5rem;
        box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
        padding: 3rem 5rem;
        border-radius: 5px;
        p{
           margin: 0.5rem 0; 
        }
        .num{
            font-size: 20px;
        }
        button{
             color: white;
            background: rgb(0,205,0);
            border: none;
            line-height: 30px;
            border-radius: 15px;
            margin-top: 10rem;
        }
    }
</style>